/**
 * Copyright (c) 2007, Blue Hole Software. All rights reserved.
 * Code licensed under the Apache 2.0 License:
 * http://www.apache.org/licenses/
 */
package org.bhf.providers.security.authentication;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.Set;

/**
 *
 */
@Entity
@Table( name = "ROLES" )
public class Role
{
    private long            id;
    private String          name;
    private Set<RoleMap>    roleMap;

    public org.bhf.security.common.Role asRole()
    {
        return new org.bhf.security.common.Role( name );
    }

    @Id
    @GeneratedValue( strategy = GenerationType.AUTO )
    public long             getId()
    {
        return id;
    }

    public void             setId( final long id )
    {
        this.id = id;
    }

    public String           getName()
    {
        return name;
    }

    public void             setName( final String name )
    {
        this.name = name;
    }

    @OneToMany( cascade = {CascadeType.ALL} )
    public Set<RoleMap>     getRoleMap()
    {
        return roleMap;
    }

    public void             setRoleMap( final Set<RoleMap> roleMap )
    {
        this.roleMap = roleMap;
    }
}
